<?php
/**
 * Created by PhpStorm.
 * User: sunku
 * Date: 2018/3/7
 * Time: 16:22
 */

namespace Admin\Logic;
use Think\Model;

class CommonSetLogic extends Model
{
    protected $trueTableName = 'wz_common_set';

    /**
     * 获取列表不分页
     * @param $params
     * @return mixed
     */
    public function getAllCommonSetList($params){
        $result = D('Resource/CommonSet','Service')->getAllCommonSetList($params);
        return $result;
    }

    /**
     * @param $params
     * @return mixed
     */
    public function getCommonSetInfo($params){
        $result = D('Resource/CommonSet','Service')->getCommonSetInfo($params);
        return $result;
    }

    /**
     * @param $params
     * @return string
     */
    public function saveCommonSet($params){
        $id = isset($params['id'])?intval($params['id']):'';
        $status = isset($params['status'])?intval($params['status']):'';
        $title = isset($params['title'])?strval($params['title']):'';
        $data = isset($params['data'])?strval($params['data']):'';

        $play_data = [];
        $id && $play_data['id'] = $id;
        $title && $play_data['title'] = $title;
        $data && $play_data['data'] = $data;
        $status && $play_data['status'] = $status;
        if(!$id){
            $result = D('Resource/CommonSet','Service')->addCommonSet($params);
        }else{
            $result = D('Resource/CommonSet','Service')->updateCommonSetInfo($params);
        }

        if(!$result){
            return Response(202,"网络请求失败");
        }
        return Response(999,"请求成功");
    }

}